package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.UserFavors;
import cn.wolfcode.wolf2w.repository.UserFavorsRepository;
import cn.wolfcode.wolf2w.service.IUserFavorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFavorsServiceImpl implements IUserFavorsService {
    @Autowired
    private UserFavorsRepository repository;
    @Autowired
    private MongoTemplate template;
    @Override
    public void save(UserFavors userFavors) {
        userFavors.setId(null);
        repository.save(userFavors);
    }

    @Override
    public void update(UserFavors userFavors) {
        repository.save(userFavors);
    }

    @Override
    public void delete(String id) {
        repository.deleteById(id);
    }

    @Override
    public UserFavors get(String id) {
        return repository.findById(id).orElse(null);
    }

    @Override
    public List<UserFavors> list() {
        return repository.findAll();
    }

    @Override
    public UserFavors findByUid(String uid) {
        return repository.findByUid(uid);
    }
}
